package com.gudaomai.ekproject.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.gudaomai.ekproject.common.EkBaseMapper;
import com.gudaomai.ekproject.entity.Page;

/**
 * <p>
 * 页面 Mapper 接口
 * </p>
 *
 * @author zenghualu
 * @since 2017-06-26
 */
public interface PageMapper extends EkBaseMapper<Page> {

	@Select("select * from page where name=#{name}")
	public Page getPageByName(@Param("name") String name);

	@Select("select max(sort) from page where project_id=#{projectid}")
	public Object getMaxOrder(@Param("projectid") String projectId);

	@Select("select * from page where page.sort = (select max(page1.sort) from page page1 inner join (select * from page where id = #{id}) page2 on page1.pid = page2.pid and page1.project_id = page2.project_id where page1.sort < page2.sort) and page.project_id=(select page3.project_id from page page3 where page3.id=#{id})")
	public Page getLastPage(@Param("id") String id);

	@Select("select * from page where page.sort = (select min(page1.sort) from page page1 inner join (select * from page where id = #{id}) page2 on page1.pid = page2.pid and page1.project_id = page2.project_id where page1.sort > page2.sort) and page.project_id =(select page3.project_id from page page3 where page3.id=#{id})")
	public Page getNextPage(@Param("id") String id);
}